package com.rfsp.mcp.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rfsp.common.base.BaseService;
import com.rfsp.mcp.mapper.HospitalMapper;
import com.rfsp.common.mapper.OrgMapper;
import com.rfsp.common.pojo.po.OrgPO;
import com.rfsp.mcp.pojo.sdto.HospitalSDTO;
import com.rfsp.common.pojo.sdto.PageSDTO;
import com.rfsp.mcp.pojo.vo.HospitalVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HospitalService extends BaseService<OrgPO> {

    @Autowired
	HospitalMapper mapper;

	@Autowired
	OrgMapper orgMapper;

	public PageInfo<HospitalVO> get(HospitalSDTO sdto, PageSDTO pageSdto){
        if(pageSdto!=null){
            PageHelper.startPage(pageSdto.getPageNum(), pageSdto.getPageSize());
        }
        List<HospitalVO> voList=mapper.get(sdto);
        PageInfo<HospitalVO> page = new PageInfo(voList);
        return page;
    }
	public List<HospitalVO> get(HospitalSDTO sdto){
		List<HospitalVO> voList=mapper.get(sdto);
		return voList;
	}
	public HospitalVO getById(Long id){
		if(id==null){
			return null;
		}
		OrgPO org=orgMapper.selectByPrimaryKey(id);
		HospitalVO vo=new HospitalVO();
		BeanUtils.copyProperties(org,vo);
		return vo;
	}
	public void combo(HospitalVO vo){
    }
    public void combo(List<HospitalVO> voList){
        for(HospitalVO vo:voList ){
            combo(vo);
        }
    }

	public PageInfo<HospitalVO> findByWhere(HospitalSDTO sdto, PageSDTO pageSdto) {
		if(pageSdto!=null){
			PageHelper.startPage(pageSdto.getPageNum(), pageSdto.getPageSize());
		}
		List<HospitalVO> voList=mapper.findByWhere(sdto);
		PageInfo<HospitalVO> page = new PageInfo(voList);
		return page;
	}
}
